var D = document;
var rerror = "unknown";

function get_elem(id) {
  var itm = null;
  if (D.getElementById) {
    itm = D.getElementById(id);
  } else if (D.all){
    itm = D.all[id];
  } else if (D.layers){
    itm = D.layers[id];
  }
  return itm;
}
function expMenu(id,show_hide) {
  var itm = get_elem(id);
  if (!itm) {
    // do nothing
  }
  else if (itm.style) {
    if(show_hide!=undefined) { itm.style.display = show_hide; } 
  else if (itm.style.display == "none") { 
    itm.style.display = ""; }
  else { itm.style.display = "none"; }
  } else { alert(show_hide); itm.visibility = "show"; }
}
function ShowHide(id1,id2,show_hide) {
  if (id1!=undefined) expMenu(id1,show_hide);
  if (id2!=undefined) expMenu(id2,show_hide);
}
function jssend(theURL,p) {
  try{ 
	var s=D.createElement('script')
	s.type="text/javascript"
            s.src=theURL+"&linkID="+p+"&random="+Math.random();
	D.body.appendChild(s);
	return false;
  }catch(e) { 
	window.location = theURL; 
	return true; 
  }
}
function create_request(error) {
  request = "";
  try {
	request = new ActiveXObject("Msxml2.XMLHTTP"); 
  } catch(e) { rerror = e; }
  if(!request) try {
	request = new ActiveXObject("Microsoft.XMLHTTP");
  } catch(e) { rerror = e; }
  if(!request&&(typeof XMLHttpRequest != "undefined")) try {
	request = new XMLHttpRequest();
  } catch(e) { rerror = e; }
  return request;
}
function do_url(pid) { window.location = base_url+'&act=SF&pid='+pid+'&st=0&f='+D.forummenu.f.value+'#List'; }
function buddy_pop() { window.open('index.php?act=buddy&s='+session_id, 'BrowserBuddy','width=250,height=500,resizable=yes,scrollbars=yes'); }
function chat_pop(cw,ch) { window.open('index.php?s='+session_id+'&act=chat&pop=1','Chat','width='+cw+',height='+ch+',resizable=yes,scrollbars=yes'); }
function multi_page_jump( url_bit, total_posts, per_page ){
  pages = 1; cur_st = parseInt(st); cur_page  = 1;
  if ( total_posts % per_page == 0 ) { pages = total_posts / per_page; } else { pages = Math.ceil( total_posts / per_page ); }
  msg = tpl_q1+" "+pages;
  if ( cur_st > 0 ) { cur_page = cur_st / per_page; cur_page = cur_page -1; }
  show_page = 1;
  if ( cur_page < pages )  { show_page = cur_page+1; }
  if ( cur_page >= pages ) { show_page = cur_page - 1; } else { show_page = cur_page+1; }
  userPage = prompt( msg, show_page );
  if ( userPage > 0  )
  {
	if ( userPage < 1 )     {    userPage = 1;  }
	if ( userPage > pages ) { userPage = pages; }
	if ( userPage == 1 ) { start = 0; } else { start = (userPage - 1) * per_page; }
	window.location = url_bit+"&st="+start;
  }
}
function contact_admin(admin_email_one, admin_email_two) { window.location = 'mailto:'+admin_email_one+'@'+admin_email_two+'?subject=Error on the forums'; }
function do_url(pid) { window.location = base_url+'&act=SF&pid='+pid+'&st=0&f='+D.forummenu.f.value+'#List'; }
function pm_popup() { window.open('index.php?act=Msg&CODE=99&s='+session_id,'NewPM','width=500,height=250,resizable=yes,scrollbars=yes'); }
function a_go_to(code,pid,mode,topic_id,forum_id,other,st_mode) { window.location.href=get_url(1,mode,code,pid,topic_id,forum_id,other,st_mode); }
function go_to(code,pid,mode,topic_id,forum_id,other,st_mode) { window.location.href=get_url(0,mode,code,pid,topic_id,forum_id,other,st_mode); }
function get_url(auth_mode,mode,code,pid,topic_id,forum_id,other,st_mode,do_not_add_base) {
  var theURL = "";
  if ( !topic_id ) { topic_id=tid; }
  if ( !forum_id ) { forum_id=fid; }
  if ( !mode )     { mode="Post"; }
  if ( do_not_add_base != 1 ) { theURL += base_url; }
  theURL += "act="+mode+"&CODE="+code+"&f="+forum_id+"&t="+topic_id;
  if ( pid )       { theURL=theURL+"&p="+pid; }
  if ( auth_mode ) { theURL=theURL+"&auth_key="+auth_key; }
  if ( st_mode != "0" ) { theURL=theURL+"&st="+st };
  if ( other )     { theURL=theURL+other; }
  return theURL;
}
function PopUp(url,name,width,height,center,resize,scroll,posleft,postop) {
  if (posleft != 0) { x = posleft }
  if (postop  != 0) { y = postop  }
  if (!scroll) { scroll = 1 }
  if (!resize) { resize = 1 }
  if ((parseInt (navigator.appVersion) >= 4 )&&(center))
  {
	X = (screen.width  - width ) / 2;
	Y = (screen.height - height) / 2;
  }
  if (scroll != 0) { scroll = 1 }
  var Win = window.open( url, name, 'width='+width+',height='+height+',top='+Y+',left='+X+',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
}
function decode(h) {
   var url = h.href;
   url 	   = url.replace(/%_/g  	, "%"      );
   url 	   = url.replace(/sc_ript/g, "script" );
   h.href  = url;
}
function ccca(cb,style) {
 var d,i;
 while(cb.tagName!='TR') cb=cb.parentNode;
 cb.dark=cb.dark?cb.dark=d=false:cb.dark=d=true;
 cb=cb.cells;
 for(i=0;i<cb.length;i++) cb[i].className=d?(cb[i].oldClass=cb[i].className,style):cb[i].oldClass;
}